home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Hackers Handbook - Millenium Edition
/
Hackers Handbook.iso
/
files
/
c_scripts
/
apoc-crack.c
< prev
next >
Wrap
C/C++ Source or Header
|
1998-12-05
|
6KB
|
218 lines
/* apoc-crack.c by Adam Rogoyski (apoc@laker.net) Temperanc on EFNet irc
* Copyright (C) 1997 Adam Rogoyski
* Simple Brute Force unix password cracker, tries every printable 7-bit
* ascii characters.
* warning: This program may take thousands of years to finish one run.
* usage: ./apoc-crack [file with encrypted password in it]
* compile: gcc -o apoc-crack apoc-crack.c
* --- GNU General Public License Disclamer ---
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*/
#include <crypt.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <stdlib.h>
#include <unistd.h>
int
main (int argc, char **argv)
{
char salt[3];
char encrypted[14];
FILE *fp;
char *temp = malloc(14 * sizeof(char));
char temppw[9];
int flag = 0;
char i = 0; char j = 0; char k = 0; char l = 0;
char m = 0; char n = 0; char o = 0; char p = 0;
if (argc == 2)
{
if ((fp = fopen(argv[1], "r")) == NULL)
exit (EXIT_FAILURE);
else
{
fgets (encrypted, 14, fp);
salt[0] = encrypted[0];
salt[1] = encrypted[1];
salt[2] = '\0';
}
}
else
exit (EXIT_FAILURE);
temppw[1] = '\0';
for (i = 33; i < 126; i++)
{
temppw[0] = i;
temp = (char *) crypt(temppw, salt);
if (strcmp(encrypted, temp) == 0)
{
printf ("%s = %s \a\n", encrypted, temppw);
flag = 1;
break;
}
}
if (flag) { exit (EXIT_SUCCESS); }
else { printf ("Password is at least 2 Characters Long\n"); }
temppw[2] = '\0';
for (i = 33; i < 126; i++) {
if (flag) { exit (EXIT_SUCCESS); }
for (j = 33; j < 126; j++)
{
temppw[0] = i; temppw[1] = j;
temp = (char *) crypt(temppw, salt);
if (strcmp(encrypted, temp) == 0)
{
printf ("%s = %s \a\n", encrypted, temppw);
flag = 1;
break;
}
} }
if (flag) { exit (EXIT_SUCCESS); }
else { printf ("Password is at least 3 Characters Long\n"); }
temppw[3] = '\0';
for (i = 33; i < 126; i++) {
for (j = 33; j < 126; j++) {
if (flag) { exit (EXIT_SUCCESS); }
for (k = 33; k < 126; k++)
{
temppw[0] = i; temppw[1] = j; temppw[2] = k;
temp = (char *) crypt(temppw, salt);
if (strcmp(encrypted, temp) == 0)
{
printf ("%s = %s \a\n", encrypted, temppw);
flag = 1;
break;
}
} } }
if (flag) { exit (EXIT_SUCCESS); }
else { printf ("Password is at least 4 Characters Long\n"); }
temppw[4] = '\0';
for (i = 33; i < 126; i++) {
for (j = 33; j < 126; j++) {
for (k = 33; k < 126; k++) {
if (flag) { exit (EXIT_SUCCESS); }
for (l = 33; l < 126; l++)
{
temppw[0] = i; temppw[1] = j; temppw[2] = k; temppw[3] = l;
temp = (char *) crypt(temppw, salt);
if (strcmp(encrypted, temp) == 0)
{
printf ("%s = %s \a\n", encrypted, temppw);
flag = 1;
break;
}
} } } }
if (flag) { exit (EXIT_SUCCESS); }
else { printf ("Password is at least 5 Characters Long\n"); }
temppw[5] = '\0';
for (i = 33; i < 126; i++) {
for (j = 33; j < 126; j++) {
for (k = 33; k < 126; k++) {
for (l = 33; l < 126; l++) {
if (flag) { exit (EXIT_SUCCESS); }
for (m = 33; m < 126; m++)
{
temppw[0] = i; temppw[1] = j; temppw[2] = k; temppw[3] = l;
temppw[4] = m;
temp = (char *) crypt(temppw, salt);
if (strcmp(encrypted, temp) == 0)
{
printf ("%s = %s \a\n", encrypted, temppw);
flag = 1;
break;
}
} } } } }
if (flag) { exit (EXIT_SUCCESS); }
else { printf ("Password is at least 6 Characters Long\n"); }
temppw[6] = '\0';
for (i = 33; i < 126; i++) {
for (j = 33; j < 126; j++) {
for (k = 33; k < 126; k++) {
for (l = 33; l < 126; l++) {
for (m = 33; m < 126; m++) {
if (flag) { exit (EXIT_SUCCESS); }
for (n = 33; n < 126; n++)
{
temppw[0] = i; temppw[1] = j; temppw[2] = k; temppw[3] = l;
temppw[4] = m; temppw[5] = n;
temp = (char *) crypt(temppw, salt);
if (strcmp(encrypted, temp) == 0)
{
printf ("%s = %s \a\n", encrypted, temppw);
flag = 1;
break;
}
} } } } } }
if (flag) { exit (EXIT_SUCCESS); }
else { printf ("Password is at least 7 Characters Long\n"); }
temppw[7] = '\0';
for (i = 33; i < 126; i++) {
for (j = 33; j < 126; j++) {
for (k = 33; k < 126; k++) {
for (l = 33; l < 126; l++) {
for (m = 33; m < 126; m++) {
for (n = 33; n < 126; n++) {
if (flag) { exit (EXIT_SUCCESS); }
for (o = 33; o < 126; o++)
{
temppw[0] = i; temppw[1] = j; temppw[2] = k; temppw[3] = l;
temppw[4] = m; temppw[5] = n; temppw[6] = o;
temp = (char *) crypt(temppw, salt);
if (strcmp(encrypted, temp) == 0)
{
printf ("%s = %s \a\n", encrypted, temppw);
flag = 1;
break;
}
} } } } } } }
if (flag) { exit (EXIT_SUCCESS); }
else { printf ("Password is at least 8 Characters Long\n"); }
temppw[8] = '\0';
for (i = 33; i < 126; i++) {
for (j = 33; j < 126; j++) {
for (k = 33; k < 126; k++) {
for (l = 33; l < 126; l++) {
for (m = 33; m < 126; m++) {
for (n = 33; n < 126; n++) {
for (o = 33; o < 126; o++) {
if (flag) { exit (EXIT_SUCCESS); }
for (p = 33; p < 126; p++)
{
temppw[0] = i; temppw[1] = j; temppw[2] = k; temppw[3] = l;
temppw[4] = m; temppw[5] = n; temppw[6] = o; temppw[7] = p;
temp = (char *) crypt(temppw, salt);
if (strcmp(encrypted, temp) == 0)
{
printf ("%s = %s \a\n", encrypted, temppw);
flag = 1;
break;
}
} } } } } } } }
if (flag) { exit (EXIT_SUCCESS); }
else { printf ("Password uses characters other than 7-bit Ascii\n"); }
return EXIT_SUCCESS;
}